# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libplist
pkgver=2.2.0
pkgrel=2
pkgdesc="library to handle Apple Property List format whereas it's binary or XML"
url="https://libimobiledevice.org/"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="py3-setuptools swig python3-dev glib-dev cython
	automake autoconf libtool"
checkdepends="diffutils"
subpackages="
	$pkgname-static
	$pkgname-dev
	py3-$pkgname:_py3
	$pkgname-util
	$pkgname++:cxx
	$pkgname-doc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/libimobiledevice/libplist/archive/$pkgver.tar.gz"

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man
	make
}

check() {
	# https://github.com/libimobiledevice/libplist/issues/118
	case "$CARCH" in
		arm*) return 0;;
	esac

	make check -j1 # https://github.com/libimobiledevice/libimobiledevice/issues/777
}

package() {
	make DESTDIR="$pkgdir" install
}

util() {
	pkgdesc="Util for libplist"
	amove usr/bin
}

_py3() {
	pkgdesc="Python bindings for libplist"
	amove usr/lib/python3*
}

cxx() {
	pkgdesc="C++ bindings to libplist"
	amove usr/lib/*++*.so.*
}

sha512sums="16038a6cca3a25874e6f21b37c9088ffc8021a65e3d09046e01d5a00180e732f7e4043a0e63a60ec7ee7460bc6615daa64fa5db2ae9cea08566d8c1b02698834  libplist-2.2.0.tar.gz"
